<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateUserHouse extends Migrator
{
    public function up()
    {
        $table = $this->table('user_house',['signed' =>false,'comment'=>'房子产品表']);
        $table->addColumn('user_id','integer',['limit'=>10,'comment'=>'用户id'])
            ->addForeignKey('user_id', 'user', 'id', ['delete'=> 'CASCADE'])
            ->addColumn('house_owner','string',['limit'=>50,'default'=>'','comment'=>'房屋所有权人'])
            ->addColumn('house_number','string',['limit'=>255,'default'=>'','comment'=>'房权证编号'])
            ->addColumn('province','string',['limit'=>60,'default'=>'','comment'=>'所属省份'])
            ->addColumn('city','string',['limit'=>60,'default'=>'','comment'=>'所属城市'])
            ->addColumn('district','string',['limit'=>60,'default'=>'','comment'=>'所属区域'])
            ->addColumn('address','string',['limit'=>255,'default'=>'','comment'=>'具体地址'])
            ->addColumn('record_time','integer',['limit'=>10,'default'=>0,'comment'=>'登记时间'])
            ->addColumn('nature_id','integer',['limit'=>11,'comment'=>'房屋性质id'])
            ->addForeignKey('nature_id', 'house_nature', 'id', ['delete'=> 'CASCADE'])
            ->addColumn('create_time','integer',['limit'=>10,'default'=>time(),'signed'=>false])
            ->create();
    }

    public function down()
    {
        $this->dropTable('house');
    }
}
